package activity.personal.qianbao;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.hutoubenjg.R;

import java.util.Observable;
import java.util.Observer;

import base.BaseActivity;
import presenter.SysTemPresenter;
import util.utls.ByAlert;
import util.utls.IsUtilUid;
import util.utls.OnPasswordInputFinish;
import util.utls.PasswordView;
import util.volley.ResultEntity;


/**
 * 忘记原支付密码(2.填写支付密码)
 */
public class WangJiZhiFuPassTwoActivity extends BaseActivity implements Observer {
    TextView tvTitle;
    ImageView back;

    PasswordView pwdView;// 支付密码
    SysTemPresenter presenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wang_ji_zhi_fu_pass_three);
        tvTitle.setText(R.string.chongzhi_zhifu_pass);
        presenter = new SysTemPresenter(this);
        final PasswordView pwdView = (PasswordView) findViewById(R.id.pwd_view);

        // 添加密码输入完成的响应
        pwdView.setOnFinishInput(new OnPasswordInputFinish() {
            @Override
            public void inputFinish() {
                // 输入完成后跳转
                // 也就是说——>实现你的交易逻辑什么的在这里写
                String pwd = pwdView.getStrPassword();
                presenter.onSttringPayPwd(IsUtilUid.isUid(), pwd);

            }
        });
    }

    @Override
    protected void onInit() {


    }

    @Override
    protected void onReadIntent(Bundle bundle) {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.close_icon:
                finish();
                break;

            default:
                break;
        }
    }

    @Override
    public void update(Observable observable, Object data) {
        ResultEntity entity = handlerError(data);
        if (entity != null) {
            IsUtilUid.tianjia(entity);
            if (entity.getEventType() == presenter.SttringPay_success) {
                ByAlert.alert(entity.getData() + "");
                Intent intent=new Intent("WangJIMima");
                sendBroadcast(intent);
                finish();
            }
        }

    }
}
